Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kuwait Theme: Activity Check-in component #2562

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

FaithDaka
Copy link
Collaborator

@FaithDaka FaithDaka commented Nov 26, 2024

PR Checklist

  • PR title descriptive (can be used in release notes)

Description

plh_activity_check_in created and styled. Corresponding debug sheet: Link

Author Notes

plh_activity_check_in component with the following parameter_list:

  • id: Activity identifier.
  • title: The title of the component attached to the bottom
  • locked_icon_asset: Icon that appears next to the title while the component is locked
  • locked_image_asset: Illustration that appears while component is locked
  • unlocked_icon_asset: Icon that appears next to the title while the component is unlocked
  • unlocked_image_asset: Illustration that appears while component is unlocked

Git Issues

Closes #2539

Screenshots

Design Locked Component Unlocked Component

Copy link
Collaborator

@jfmcquade jfmcquade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to have this scaffolded out. I assume you're seeing the logic for handling the countdown and unlock as a placeholder that should be replaced by logic that connects to our real system of handling this data? @esmeetewinkel is that something that has been discussed/thought through already, or shall we add it to our meeting agenda?

I would also say that it probably makes sense to style the component to be centred within its div. Laying out the element so that it sits to the side of another element is something that should be handled at the authoring level (i.e. by putting the elements inside a display_group component).

import { getStringParamFromTemplateRow } from "src/app/shared/utils";

interface IActivityCheckInParams {
id: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be renamed activity_id to improve clarity for authors

params: Partial<IActivityCheckInParams> = {};

countDownDays: number = 6; // Number of days being counted down
daysLeft: number = 6; // Days until unlock
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be exposed as authorable params

}

// Calculates the days until check in
private checkInTimer() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic will need to be reworked to handle how we actually plan on managing the unlock dates of the various activities. @esmeetewinkel, is that something we should discuss in our next meeting?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes let's discuss in our next meeting. My initial thoughts are in my comment below

Copy link
Collaborator

@esmeetewinkel esmeetewinkel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how you're proposing to author the "days left". One way that would be intuitive to me is that the component can have a parameter (maybe unlock_at) which is a timestamp of the moment of unlocking. If this parameter value is

  • falsy (undefined or empty string): don't show the "days left" progress bar + text. Button is disabled.
    image
  • a time stamp in the future: compute how many days left and display progress bar + text. Button is disabled.
    image
  • a time stamp in the past: don't show the "days left" progress bar + text. Button is enabled.
    image

Edited: thinking about it further I think we also need something like a start_countdown_at parameter

@chrismclarke chrismclarke removed their request for review November 27, 2024 18:05
@jfmcquade
Copy link
Collaborator

jfmcquade commented Dec 3, 2024

@FaithDaka: @esmeetewinkel and I discussed how we're going to handle the countdown settings, and our plan requires the following:

I've authored a new row in the component demo template to represent how the authoring should work, just as an example until the logic to handle the parameters is fleshed out:
Screenshot 2024-12-03 at 12 09 38

The proposed changes are:

  • Add two new params to this component
    • start_date
      • A timestamp as a string or date object
    • countdown_text_list
      • A list of text strings to display for each day of the countdown. E.g. "in 1 day", "in 2 days", "in 3 days",... etc.
      • Whilst obviously it would be more convenient to construct these strings dynamically, in order to have them properly translated we need to supply them manually

Then the plh_activity_check_in will need to handle the following logic:

  • Add the days_to_count_down to the start_date value to calculate the unlock date. We want to ignore the time and just calculate the days, so that the unlock will happen at midnight on the target day.
    • use the date-fns library to accomplish this, it is already installed on the repo
  • On init, the component should calculate the days until the unlock date and use this calculation to display in the expected way.
    • It should show the text string associated with the corresponding number of days
      • You may need to convert the countdown_text_list to an array (splitting on , and trimming), or you may find that this is already parsed (as a result of the parameter name ending with _list)
      • You can assume that the array contains the values in order, from least number of days to most number of days.
      • If the array is does not have an entry for the number of days (i.e. the array provided is not long enough), use the display the last element in the array

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Work on app features/modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Kuwait Theme - Check-in Component
3 participants